package algorithm.leetcode.simple;

/*
  给定一个整数 n，返回 n! 结果尾数中零的数量。
  说明: 你算法的时间复杂度应为 O(log n) 。
 */

/**
 * @author jack.wu
 * @version 1.0
 * @date 2020/10/16
 */
public class Question172 {

    public static void main(String[] args) {
        Question172 question = new Question172();
        int zeroes = question.trailingZeroes(5);
        System.out.println(zeroes);
    }

    public int trailingZeroes(int n) {
        int zeroCount = 0;
        for (int i = 5; i <= n; i += 5) {
            int cur = i;
            while (cur % 5 == 0) {
                zeroCount++;
                cur /= 5;
            }
        }
        return zeroCount;
    }
}
